package _thread_lock._futurepattern._future;

import java.util.concurrent.TimeUnit;

/**
 * @Author: huangya
 * @Date: 2020/10/19
 * @Description:
 */
public class Test11111 {

    public static void main(String[] args) throws InterruptedException {
        FutureService<String, Integer> service = FutureService.newService();
        Future<?> future = service.submit(new Task<String, Integer>() {
            @Override
            public Integer get(String input) {
                try {
                    TimeUnit.SECONDS.sleep(3);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                return input.length();
            }
        }, "Hello");
        System.out.println(future.get());
    }
}
